#include "ANN_Header.h"

namespace ann
{
	
	BPNode::BPNode(void)
	{
	}
	
	
	BPNode::~BPNode(void)
	{
	}

	void BPNode::Update(void)
	{
		std::list<Tube*>::iterator outBeginItr = this->GetOutTubeBeginItr();
		std::list<Tube*>::iterator outEndItr = this->GetOutTubeEndItr();
        std::list<Tube*>::iterator inBeginItr = this->GetInTubeBeginItr();
		std::list<Tube*>::iterator inEndItr = this->GetInTubeEndItr();
        double _s_value = 0.0;

		for ( ; inBeginItr != inEndItr; ++inBeginItr)
		{
            _s_value += (*inBeginItr)->GetValue() * (*inBeginItr)->GetWeight();
		}

        _s_value = ann::Tansig(_s_value);
		this->SetValue( _s_value );

		for ( ; outBeginItr != outEndItr; ++outBeginItr)
		{
            (*outBeginItr)->SetValue(_s_value);
		}


		return;
	}
}
